// pages/task/order/order.js
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    orderList: [],
    noMore: 0,
    page: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getOrderList();
  },

  getOrderList() {
    let page = this.data.page
    let orderList = this.data.orderList
    app.util.request({
      url: '/commission/orderList',
      data: {
        page: page  
      }
    }).then((res) => {
      if (res.data.length > 0) {
        this.setData({
          orderList: orderList.concat(res.data),
          noMore: 0,
          page: page + 1
        });
      } else {
        this.setData({
          noMore: 1
        });
      }
    });
  },
  refreshList: function () {
    this.setData({
      page: 1,
      orderList: []
    });
    this.getOrderList();
  },
  onPullDownRefresh() {
    this.refreshList();
    setTimeout(() => {
      wx.hideNavigationBarLoading(); //完成停止加载
      wx.stopPullDownRefresh(); //停止下拉刷新
    }, 500);
  },
  onReachBottom() {
    this.getOrderList();
  }
})